﻿USE [master]
GO
/****** Object:  Database [MBS]    Script Date: 05/20/2012 16:32:58 ******/
CREATE DATABASE [MBS] ON  PRIMARY 
( NAME = N'MBS', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\MBS.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'MBS_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\MBS_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [MBS] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MBS].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MBS] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [MBS] SET ANSI_NULLS OFF
GO
ALTER DATABASE [MBS] SET ANSI_PADDING OFF
GO
ALTER DATABASE [MBS] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [MBS] SET ARITHABORT OFF
GO
ALTER DATABASE [MBS] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [MBS] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [MBS] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [MBS] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [MBS] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [MBS] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [MBS] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [MBS] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [MBS] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [MBS] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [MBS] SET  DISABLE_BROKER
GO
ALTER DATABASE [MBS] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [MBS] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [MBS] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [MBS] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [MBS] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [MBS] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [MBS] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [MBS] SET  READ_WRITE
GO
ALTER DATABASE [MBS] SET RECOVERY SIMPLE
GO
ALTER DATABASE [MBS] SET  MULTI_USER
GO
ALTER DATABASE [MBS] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [MBS] SET DB_CHAINING OFF
GO
USE [MBS]
GO
/****** Object:  Table [dbo].[Movie]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Movie](
	[MovieID] [int] IDENTITY(1,1) NOT NULL,
	[MovieTitle] [nvarchar](max) NULL,
	[Description] [nvarchar](max) NULL,
	[Duration] [float] NULL,
	[Genre] [nvarchar](20) NULL,
	[Cast] [nvarchar](50) NULL,
	[Rating] [float] NULL,
	[ImageURL] [nvarchar](100) NULL,
	[ReleaseDate] [datetime] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Movie] PRIMARY KEY CLUSTERED 
(
	[MovieID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Food]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Food](
	[FoodID] [int] NOT NULL,
	[Category] [nvarchar](20) NULL,
	[ImageURL] [nvarchar](max) NULL,
	[Name] [nvarchar](max) NULL,
	[Price] [money] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK__Food__856DB3CB014935CB] PRIMARY KEY CLUSTERED 
(
	[FoodID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Cinema]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Cinema](
	[CinemaID] [int] IDENTITY(1,1) NOT NULL,
	[Location] [nvarchar](20) NULL,
	[CinemaName] [nvarchar](30) NOT NULL,
	[NumOfScreens] [int] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Cinema] PRIMARY KEY CLUSTERED 
(
	[CinemaID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Cinema] ON [dbo].[Cinema] 
(
	[CinemaName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[User]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[Role] [nvarchar](50) NULL,
	[UserName] [nvarchar](50) NULL,
	[Password] [nvarchar](50) NULL,
	[IsDeleted] [bit] NOT NULL,
	[Contact] [bigint] NULL,
	[EmailID] [nvarchar](50) NULL,
	[TotalRewardPoints] [int] NULL,
	[Preferences] [nvarchar](20) NULL,
	[UserNotified] [nvarchar](10) NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Screen]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Screen](
	[CinemaID] [int] NOT NULL,
	[ScreenNo] [int] NOT NULL,
	[NumOfSeats] [int] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Screen] PRIMARY KEY CLUSTERED 
(
	[CinemaID] ASC,
	[ScreenNo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MovieSchedule]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MovieSchedule](
	[MovieScheduleID] [int] IDENTITY(1,1) NOT NULL,
	[StartDate] [date] NULL,
	[EndDate] [date] NULL,
	[ShowStartTime] [datetime] NULL,
	[ShowEndTime] [datetime] NULL,
	[WeekDateFare] [money] NULL,
	[WeekEndFare] [money] NULL,
	[IsDeleted] [bit] NOT NULL,
	[CinemaID] [int] NOT NULL,
	[ScreenNo] [int] NOT NULL,
	[MovieID] [int] NOT NULL,
 CONSTRAINT [PK_MovieSchedule] PRIMARY KEY CLUSTERED 
(
	[MovieScheduleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ShowTime]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ShowTime](
	[ShowID] [int] NOT NULL,
	[Fare] [money] NULL,
	[ShowDate] [date] NULL,
	[SeatsAvailable] [xml] NULL,
	[MovieScheduleID] [int] NOT NULL,
	[IsDelted] [bit] NOT NULL,
 CONSTRAINT [PK_ShowTime] PRIMARY KEY CLUSTERED 
(
	[ShowID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Booking]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Booking](
	[BookingID] [int] NOT NULL,
	[BookingDate] [datetime] NULL,
	[Seatnumbers] [xml] NULL,
	[Amount] [money] NULL,
	[RewardPointsGained] [int] NULL,
	[ShowTimeID] [int] NOT NULL,
	[UserID] [int] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Booking] PRIMARY KEY CLUSTERED 
(
	[BookingID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[FoodOrder]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FoodOrder](
	[OrderID] [int] IDENTITY(1,1) NOT NULL,
	[BookingID] [int] NOT NULL,
	[ItemsOrdered] [xml] NULL,
	[Amount] [money] NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_FoodOrder_1] PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[FoodOrderItem]    Script Date: 05/20/2012 16:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FoodOrderItem](
	[OrderID] [int] NOT NULL,
	[FoodID] [int] NOT NULL,
	[Quantity] [int] NULL,
 CONSTRAINT [PK_FoodOrderItem] PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC,
	[FoodID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Screen_Cinema]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[Screen]  WITH CHECK ADD  CONSTRAINT [FK_Screen_Cinema] FOREIGN KEY([CinemaID])
REFERENCES [dbo].[Cinema] ([CinemaID])
GO
ALTER TABLE [dbo].[Screen] CHECK CONSTRAINT [FK_Screen_Cinema]
GO
/****** Object:  ForeignKey [FK_MovieSchedule_Screen]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[MovieSchedule]  WITH CHECK ADD  CONSTRAINT [FK_MovieSchedule_Screen] FOREIGN KEY([MovieID])
REFERENCES [dbo].[Movie] ([MovieID])
GO
ALTER TABLE [dbo].[MovieSchedule] CHECK CONSTRAINT [FK_MovieSchedule_Screen]
GO
/****** Object:  ForeignKey [FK_MovieSchedule_Screen1]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[MovieSchedule]  WITH CHECK ADD  CONSTRAINT [FK_MovieSchedule_Screen1] FOREIGN KEY([CinemaID], [ScreenNo])
REFERENCES [dbo].[Screen] ([CinemaID], [ScreenNo])
GO
ALTER TABLE [dbo].[MovieSchedule] CHECK CONSTRAINT [FK_MovieSchedule_Screen1]
GO
/****** Object:  ForeignKey [FK_ShowTime_MovieSchedule]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[ShowTime]  WITH CHECK ADD  CONSTRAINT [FK_ShowTime_MovieSchedule] FOREIGN KEY([MovieScheduleID])
REFERENCES [dbo].[MovieSchedule] ([MovieScheduleID])
GO
ALTER TABLE [dbo].[ShowTime] CHECK CONSTRAINT [FK_ShowTime_MovieSchedule]
GO
/****** Object:  ForeignKey [FK_Booking_ShowTime]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[Booking]  WITH CHECK ADD  CONSTRAINT [FK_Booking_ShowTime] FOREIGN KEY([ShowTimeID])
REFERENCES [dbo].[ShowTime] ([ShowID])
GO
ALTER TABLE [dbo].[Booking] CHECK CONSTRAINT [FK_Booking_ShowTime]
GO
/****** Object:  ForeignKey [FK_Booking_User]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[Booking]  WITH CHECK ADD  CONSTRAINT [FK_Booking_User] FOREIGN KEY([UserID])
REFERENCES [dbo].[User] ([UserID])
GO
ALTER TABLE [dbo].[Booking] CHECK CONSTRAINT [FK_Booking_User]
GO
/****** Object:  ForeignKey [FK_FoodOrder_Booking]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[FoodOrder]  WITH CHECK ADD  CONSTRAINT [FK_FoodOrder_Booking] FOREIGN KEY([BookingID])
REFERENCES [dbo].[Booking] ([BookingID])
GO
ALTER TABLE [dbo].[FoodOrder] CHECK CONSTRAINT [FK_FoodOrder_Booking]
GO
/****** Object:  ForeignKey [FK_FoodOrderItem_Food]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[FoodOrderItem]  WITH CHECK ADD  CONSTRAINT [FK_FoodOrderItem_Food] FOREIGN KEY([FoodID])
REFERENCES [dbo].[Food] ([FoodID])
GO
ALTER TABLE [dbo].[FoodOrderItem] CHECK CONSTRAINT [FK_FoodOrderItem_Food]
GO
/****** Object:  ForeignKey [FK_FoodOrderItem_FoodOrder]    Script Date: 05/20/2012 16:32:59 ******/
ALTER TABLE [dbo].[FoodOrderItem]  WITH CHECK ADD  CONSTRAINT [FK_FoodOrderItem_FoodOrder] FOREIGN KEY([OrderID])
REFERENCES [dbo].[FoodOrder] ([OrderID])
GO
ALTER TABLE [dbo].[FoodOrderItem] CHECK CONSTRAINT [FK_FoodOrderItem_FoodOrder]
GO
